load("//devtools/tools:defaults.bzl", "esbuild", "http_server", "ng_project", "sass_binary")

package(default_visibility = ["//visibility:public"])

sass_binary(
    name = "demo_styles",
    src = "styles.scss",
    sourcemap = False,
    deps = ["//devtools/projects/ng-devtools/src/styles:global"],
)

ng_project(
    name = "demo",
    srcs = ["main.ts"],
    deps = [
        "//:node_modules/@angular/common",
        "//:node_modules/@angular/core",
        "//:node_modules/@angular/platform-browser",
        "//:node_modules/rxjs",
        "//devtools/src/app",
    ],
)

esbuild(
    name = "bundle",
    srcs = [
        "//devtools/tools/esbuild:esbuild_base",
        "//devtools/tools/esbuild:esbuild_config_esm",
    ],
    config = "//devtools/tools/esbuild:esbuild-esm.config.mjs",
    entry_points = [":main.ts"],
    platform = "browser",
    splitting = True,
    target = "esnext",
    deps = [
        ":demo",
        "//:node_modules/@angular/cdk",
    ],
)

exports_files(["index.html"])

filegroup(
    name = "dev_app_static_files",
    srcs = [
        ":demo_styles",
        ":index.html",
        "//devtools/src/assets",
    ],
)

http_server(
    name = "devserver",
    srcs = [":dev_app_static_files"],
    port = 4200,
    tags = ["manual"],
    deps = [
        ":bundle",
    ],
)

ng_project(
    name = "demo_application_environment",
    srcs = ["demo-application-environment.ts"],
    deps = [
        "//devtools/projects/ng-devtools",
        "//devtools/src/environments",
    ],
)

ng_project(
    name = "demo_application_operations",
    srcs = [
        "demo-application-operations.ts",
        "local-storage.ts",
    ],
    deps = [
        "//:node_modules/@angular/core",
        "//devtools/projects/ng-devtools",
        "//devtools/projects/protocol",
    ],
)

ng_project(
    name = "iframe_message_bus",
    srcs = ["iframe-message-bus.ts"],
    deps = [
        "//devtools/projects/protocol",
    ],
)

ng_project(
    name = "zone-unaware-iframe_message_bus",
    srcs = ["zone-unaware-iframe-message-bus.ts"],
    deps = [
        ":iframe_message_bus",
        "//devtools/projects/protocol",
    ],
)

ng_project(
    name = "communication",
    srcs = ["communication.ts"],
)
